# Import
KRDAN_raw <-
read_csv(paste0("https://bank.stat.gl:443/sq/004c1708-6db1-4553-a019-41e76ba8a8f6", "?lang=", language),
locale = locale(encoding = "latin1"))
# Transform
KRDAN <-
KRDAN_raw %>%
rename(
"offence" = 1,
"time" = 2,
"value" = 3
) %>%
mutate(offence = offence %>% str_remove_all("[:digit:]|\\-") %>% trimws(),
offence = offence %>% fct_reorder(value))
# Plot
KRDAN %>%
ggplot(aes(
x = time,
y = value,
fill = offence
)) +
geom_col() +
theme_statgl() +
scale_fill_statgl(reverse = TRUE, guide = guide_legend(nrow = 3, reverse = TRUE)) +
theme(plot.margin = margin(10, 10, 10, 10)) +
labs(
title = sdg16$figs$fig1$title[language],
x = " ",
y = colnames(KRDAN_raw)[3],
fill = " ",
caption = sdg16$figs$fig1$cap[language]
)
StatBank # Import
SIF_raw <-
data.frame(overgreb = c(32.8, 32.8, 27.0),
tid = c("2005-2010", "2014", "2018")) %>%
as_tibble()
# Transform
SIF <-
SIF_raw %>%
rename(`Andel 18-29-årige, der har vøret udsat for seksuelle overgreb inden 18-årsalderen` = overgreb) %>%
gather(indikatorer, værdi, -tid)
# Plot
SIF_overgreb_plot <-
SIF %>%
mutate(tid = as.character(tid)) %>%
ggplot(aes(x = tid, y = værdi, fill = indikatorer)) +
geom_col() +
scale_y_continuous(labels = scales::percent_format(scale = 1, accuracy = 1, big.mark = ".",
decimal.mark = ",")) +
theme_statgl() + scale_fill_statgl(reverse = TRUE) +
theme(legend.position = "None") +
labs(
title = sdg16$figs$fig2$title[language],
x = " ",
y = " ",
caption = sdg16$figs$fig2$cap[language]
)
SIF_overgreb_plot
Befolkningsundersøgelse # Import
SUDLDM3_raw <-
read_csv(
paste0("https://bank.stat.gl:443/sq/50013c7c-14d5-4d6a-96e0-df61cb3044f3", "?lang=", language),
locale = locale(encoding = "latin1")
)
# Transform
SUDLDM3 <-
SUDLDM3_raw %>%
rename(
"causes" = 1,
"sex" = 2,
"time" = 3,
"value" = 4
)
# Plot
SUDLDM3 %>%
ggplot(aes(
x = time,
y = value,
fill = sex
)) +
geom_col() +
theme_statgl() + scale_fill_statgl(reverse = TRUE) +
scale_y_continuous(breaks = c(0, 2, 4, 6, 8, 10)) +
labs(
title = SUDLDM3[[1]][1],
y = sdg16$figs$fig3$y_lab[language],
fill = " ",
x = " ",
caption = sdg16$figs$fig3$cap[language]
)
StatBank # Import
police1_raw <-
data.frame(
Tryg = c(82.9, 81.6),
hverken = c(5.5, 7.3),
Utryg = c(10.1, 10.4),
ved_ikke = c(1.5, 0.7),
tid = c(2018 , 2019)
) %>%
as_tibble()
# Transform
police1 <-
police1_raw %>%
rename(`Hverken/eller` = hverken,
`Ved ikke/ ønsker ikke at svare` = ved_ikke) %>%
gather(svar, procent, -tid) %>%
mutate(tid = as.factor(tid))
# Plot
police1_plot <-
police1 %>%
ggplot(aes(x = svar,
y = procent,
fill = tid)) +
geom_col(position = "dodge2") +
expand_limits(y = 100) +
theme_statgl() + scale_fill_statgl() +
scale_y_continuous(labels = scales::percent_format(scale = 1, accuracy = 1, big.mark = ".",
decimal.mark = ",")) +
labs(
title = sdg16$figs$fig4$title[language],
x = " ",
y = " ",
fill = " ",
caption = sdg16$figs$fig4$cap[language]
)
police1_plot
Security survey Question: On a scale of 1-7, where 1 is ‘I basically feel safe in my neighborhood’ and 7 is ‘I basically feel insecure in my neighborhood’, how safe or insecure do you feel? Neighborhood is defined as the area immediately surrounding your residence. In the figure, the answers are grouped so that 1-3 indicate that citizens are safe in their neighborhood, 4 indicate that citizens are neither safe nor insecure, and 5-7 indicate that citizens are insecure in their neighborhoods.
Note: Taking into account the statistical uncertainty, the proportion of citizens who are safe in their neighborhoods is at the same level.
# Import
police4_raw <-
data.frame(
Tryg = c(92.0, 86.8),
hverken = c(1.5, 4.7),
Utryg = c(4.4, 7.2),
ved_ikke = c(2.2, 1.4),
tid = c(2018 , 2019)
) %>%
as_tibble()
# Transform
police4 <-
police4_raw %>%
rename(`Hverken/eller` = hverken,
`Ved ikke/ ønsker ikke at svare` = ved_ikke) %>%
gather(svar, procent,-tid) %>%
mutate(tid = as.factor(tid))
# Plot
police4_plot <-
police4 %>%
ggplot(aes(x = svar,
y = procent,
fill = tid)) +
geom_col(position = "dodge2") +
theme_statgl() + scale_fill_statgl() +
expand_limits(y = 100) +
scale_y_continuous(labels = scales::percent_format(scale = 1, accuracy = 1, big.mark = ".",
decimal.mark = ",")) +
labs(
title = sdg16$figs$fig5$title[language],
x = " ",
y = " ",
fill = " ",
caption = sdg16$figs$fig5$cap[language]
)
police4_plot
Security survey Question: On a scale of 1-7, where 1 is ‘I basically feel safe in my neighborhood’ and 7 is ‘I basically feel insecure in my neighborhood’, how safe or insecure do you feel? Neighborhood is defined as the area immediately surrounding your residence. In the figure, the answers are grouped so that 1-3 indicate that citizents are safe in their neighborhood, 4 indicate that citizens are neither safe nor insecure, and 5-7 indicate that citizents are insecure in their neighborhoods.
Note: Taking into account the statistical uncertainty, the proportion of citizens who are safe in their neighborhoods has decreased.
# Import
police5_raw <-
data.frame(
tillid = c(85.0, 89.3),
ikke_tillid = c(12.5, 7.7),
ved_ikke = c(2.5, 3.0),
tid = c(2018 , 2019)
) %>%
as_tibble()
# Transform
police5 <-
police5_raw %>%
rename(
`Tillid til politiet` = tillid,
`Ikke tillid til politiet` = ikke_tillid,
`Ved ikke/ ønsker ikke at svare` = ved_ikke
) %>%
gather(svar, procent,-tid) %>%
mutate(tid = as.factor(tid))
# Plot
police5_plot <-
police5 %>%
ggplot(aes(x = svar,
y = procent,
fill = tid)) +
geom_col(position = "dodge2") +
theme_statgl() + scale_fill_statgl() +
expand_limits(y = 100) +
scale_y_continuous(labels = scales::percent_format(scale = 1, accuracy = 1, big.mark = ".",
decimal.mark = ",")) +
labs(
title = sdg16$figs$fig6$title[language],
x = " ",
y = " ",
fill = " ",
caption = sdg16$figs$fig6$cap[language]
)
police5_plot
Security survey Question: Do you agree on the following statement? I trust the police to help me if i need it. In the diagram, answers have been categorized, making ‘Trust the Police’ equal to the number of citizens who answered affirmatively, and ‘Do not trust the Police’ equal to the number of citizens who dissent with the statement.
Note: Taking into account the statistical uncertainty, the proportion of citizens who trust the police has risen. Note however, when comparing, that the question has been asked in different contexts in the two survey years.
# Import
SAXLANST_raw <-
statgl_url("SAXLANST", lang = language) %>%
statgl_fetch(
"constituencies" = c(0),
"votes cast" = c(16, 20),
.col_code = TRUE
) %>%
as_tibble()
# Transform
SAXLANST <-
SAXLANST_raw %>%
separate(time, c("day", "month", "year")) %>%
select(-c("day", "month")) %>%
mutate(
year = year %>% as.numeric(),
year = year + 1900,
plus = case_when(
year < 1950 ~ 100,
year > 1950 ~ 0),
year = year + plus,
`votes cast` = `votes cast` %>% fct_reorder(value, sum)
) %>%
select(-ncol(.)) %>%
spread(3, 4) %>%
rename(
valid = 3,
total = 4
) %>%
mutate(
vote = valid / total * 100,
mean = mean(vote)
)
# Plot
SAXLANST %>%
ggplot(aes(
x = year,
y = vote
)) +
geom_point(size = 2) +
geom_segment(aes(
x = year,
xend = year,
y = 0,
yend = vote
)) +
scale_y_continuous(labels = scales::percent_format(
scale = 1,
accuracy = 1,
big.mark = ".",
decimal.mark = ","
)) +
theme_statgl() +
scale_fill_statgl() +
expand_limits(y = 0) +
expand_limits(y = 100) +
geom_hline(
size = 15,
alpha = 0.1,
color = "green",
yintercept = SAXLANST[["mean"]][1]
) +
labs(
title = sdg16$figs$fig9$title[language],
subtitle = SAXLANST[[2]][1],
y = " ",
x = " ",
caption = sdg16$figs$fig9$cap[language]
)
StatBank # Import
SAXKOMST_raw <-
statgl_url("SAXKOMST", lang = language) %>%
statgl_fetch(
municipality = c(0),
"votes cast" = c(15, 19),
.col_code = TRUE
) %>%
as_tibble()
# Transform
SAXKOMST <-
SAXKOMST_raw %>%
separate(time, c("day", "month", "year")) %>%
select(-c("day", "month")) %>%
mutate(
year = year %>% as.numeric(),
year = year + 1900,
plus = case_when(
year < 1950 ~ 100,
year > 1950 ~ 0),
year = year + plus,
`votes cast` = `votes cast` %>% fct_reorder(value, sum)
) %>%
select(-ncol(.)) %>%
spread(3, 4) %>%
rename(
valid = 3,
total = 4
) %>%
mutate(
vote = valid / total * 100,
mean = mean(vote)
)
# Plot
SAXKOMST %>%
ggplot(aes(
x = year,
y = vote
)) +
geom_point(size = 2) +
geom_segment(aes(
x = year,
xend = year,
y = 0,
yend = vote
)) +
scale_y_continuous(labels = scales::percent_format(
scale = 1,
accuracy = 1,
big.mark = ".",
decimal.mark = ","
)) +
theme_statgl() +
scale_fill_statgl() +
expand_limits(y = 0) +
expand_limits(y = 100) +
geom_hline(
size = 15,
alpha = 0.1,
color = "red",
yintercept = SAXKOMST[["mean"]][1],
) +
labs(
title = sdg16$figs$fig8$title[language],
subtitle = SAXKOMST[[2]][1],
y = " ",
x = " ",
caption = sdg16$figs$fig8$cap[language]
)
StatBank # Import
SAXFOLK_raw <-
statgl_url("SAXFOLK", lang = language) %>%
statgl_fetch(
municipality = c(0),
"votes cast" = c(12, 16),
.col_code = TRUE
) %>%
as_tibble()
# Transform
SAXFOLK <-
SAXFOLK_raw %>%
separate(time, c("day", "month", "year")) %>%
select(-c("day", "month")) %>%
mutate(
year = year %>% as.numeric(),
year = year + 1900,
plus = case_when(
year < 1980 ~ 100,
year > 1980 ~ 0
),
year = year + plus,
`votes cast` = `votes cast` %>% fct_reorder(value, sum)) %>%
select(-ncol(.)) %>%
spread(3, 4) %>%
rename(
valid = 3,
total = 4
) %>%
mutate(vote = valid / total * 100,
mean = mean(vote))
# Plot
SAXFOLK %>%
ggplot(aes(
x = year,
y = vote
)) +
geom_point(size = 2) +
geom_segment(aes(
x = year,
xend = year,
y = 0,
yend = vote
)) +
scale_y_continuous(labels = scales::percent_format(
scale = 1,
accuracy = 1,
big.mark = ".",
decimal.mark = ","
)) +
theme_statgl() +
scale_fill_statgl() +
expand_limits(y = 0) +
expand_limits(y = 100) +
geom_hline(
size = 15,
alpha = 0.1,
color = "blue",
yintercept = SAXFOLK[["mean"]][1]
) +
labs(
title = sdg16$figs$fig7$title[language],
subtitle = SAXFOLK[[2]][1],
y = " ",
x = " ",
caption = sdg16$figs$fig7$cap[language]
)
StatBank